package com.wkh.datastructure;

import java.util.LinkedList;

//汉诺塔
public class TowerOfHanoi {
    private static LinkedList<Integer> a = new LinkedList<>();
    private static LinkedList<Integer> b = new LinkedList<>();
    private static LinkedList<Integer> c = new LinkedList<>();
    static {

        a.addLast(20);
        a.addLast(19);
        a.addLast(18);
        a.addLast(17);
        a.addLast(16);
        a.addLast(15);
        a.addLast(14);
        a.addLast(13);
        a.addLast(12);
        a.addLast(11);
        a.addLast(10);
        a.addLast(9);
        a.addLast(8);
        a.addLast(7);
        a.addLast(6);
        a.addLast(5);
        a.addLast(4);
        a.addLast(3);
        a.addLast(2);
        a.addLast(1);
    }
    public static void move(int n, LinkedList<Integer> a,
                            LinkedList<Integer> b,
                            LinkedList<Integer> c){
        if (n == 0){
            return;
        }
        move(n-1,a,c,b);
        c.add(a.removeLast());
        print();
        move(n-1,b,a,c);
    }

    private static void print() {
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println("==================");
    }

    public static void main(String[] args) {
        print();
        move(20,a,b,c);
    }
}
